<?php

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

session_start();
loaducenter();
$jyConfig = $_G['cache']['plugin']['tom_love'];

$appid = trim($jyConfig['love_appid']);  
$appsecret = trim($jyConfig['love_appsecret']); 
include DISCUZ_ROOT.'./source/plugin/tom_love/weixin.class.php';
$weixinClass = new weixinClass($appid,$appsecret);

//即将过期用户提醒
{
		$condition = " AND renzheng=1 AND auth_due_time<=" . (time() + 30 * 24 * 60* 60);
		$userList = C::t('#tom_love#tom_love')->fetch_all_list($condition);
		
		foreach ($userList as $user)
		{
				//判断过期时间
				$days = intval(($user["auth_due_time"] - time()) / (24 * 60 * 60));
				
				//通知时间列表
				$dayList = array(30, 20, 15, 7, 5, 3, 2, 1);
				if (in_array($days, $dayList))
				{
						//消息内容
						$message = "亲爱的会员您的身份认证还有" . $days
						 . "天到期，请到微信公众号\"临沂高端社交\"的会员管理页面续费回到浪漫的平台。";
				
						//过期时间
						$dueTime = date("Y-m-d H:i:s", $user["auth_due_time"]);
						
						$weixinClass->sendAuthDueMessage($user, $message, $dueTime);
				}	
		}
}

//过期用户提醒
{
		$condition = " AND renzheng=0 AND auth_time>0 AND auth_due_time>"
		 . strtotime("2016-01-01 00:00:00") . " AND auth_due_time<" . time();
		$userList = C::t('#tom_love#tom_love')->fetch_all_list($condition);
		
		foreach ($userList as $user)
		{
				//判断过期时间
				$days = ceil((time() - $user["auth_due_time"]) / (24 * 60 * 60));
				
				//通知时间列表
				$dayList = array(30, 20, 15, 7, 6,5, 3, 2, 1);
				if (in_array($days, $dayList))
				{
						//消息内容
						$message = "亲爱的会员您已经离开我们的交友平台" . $days
						 . "天，我们很想念你，欢迎回到微信公众号\"临沂高端社交\"的会员管理页面续费回到浪漫的平台。";
				
						//过期时间
						$dueTime = date("Y-m-d H:i:s", $user["auth_due_time"]);
						
						$weixinClass->sendAuthDueMessage($user, $message, $dueTime);
				}	
		}
}